package sctu.edu.java.year2016.team07.huangsuixin.day20160523.chapter6_2;

/**
 * Created by Huang Suixin on 2016/5/23.
 * <p>
 * 2.只用for循环和if条件句实现去除空格。
 */

/**
 * 2.只用for循环和if条件句实现去除空格。
 */

import java.util.Scanner;

public class Two {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.print("请输入一串字符：");
        String s = scan.nextLine();
        String new_s = new String();
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == ' ') {
                continue;
            } else {
                new_s = new_s + s.charAt(i);
            }
        }
        System.out.println("去除空格的字符为：" + new_s);
    }
}
